import request from '@/utils/request'
import qs from 'qs';

export function fetchRoleList(params) {
  return request({
    url: '/admin/role/page',
    method: 'get',
    params: params
  })
}
export function fetchAllRole() {
  return request({
    url: '/admin/role/getAll',
    method: 'get'
  })
}

export function addRole(data) {
  return request({
    url: '/admin/role/update',
    method: 'post',
    data: data
  })
}

export function updateRole(data) {
  return request({
    url: '/admin/role/update',
    method: 'post',
    data: data
  })
}

export function deleteRole(data) {
  return request({
    url:'/admin/role/delete',
    method:'post',
    data:data
  })
}
export function getRole(id) {
  return request({
    url:'/admin/role/get/'+id,
    method:'get',
  })
}
export function getAllPermission(id) {
  return request({
    url:'/admin/role/getAllPermission',
    method:'get',
  })
}
export function getRolePermission(roleId) {
  return request({
    url:'/admin/role/getRolePermission/'+roleId,
    method:'get',
  })
}
export function updateRolePermission(params) {
  var params1 = qs.stringify(params,{ arrayFormat: 'repeat' });
  return request({
    url:'/admin/role/editRolePermission',
    method:'post',
    data:params1
  })
}
